package com.study.talk.utils.extras

import android.content.Context
import com.study.common.GSONUtil
import com.study.common.ToastUtil
import com.study.talk.di.AppModule
import java.lang.reflect.Type

fun String.useful(): Boolean {
    return this.trim().isNotEmpty()
}

fun String.useless(context: Context, msg: String): Boolean {
    if (this.trim().useful()) return false
    ToastUtil.showToast(context, msg)
    return true
}

fun <T> String.toObj(clazz: Class<T>): T {
    return GSONUtil.fromJson(this, clazz)
}

fun <T> String.toObj(type : Type): T {
    return GSONUtil.fromJson(this,type)
}

fun String.imageUrl() : String{
    return AppModule.getWebUrl() + this
}